package io.wins.vertx.entity;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import io.wins.vertx.utils.UUIDUtils;
import org.apache.commons.lang3.StringUtils;

@DataObject(generateConverter = true)
public class Image {
    public final String id;
    public String imagePath;
    public String imageBase;
    public long createdOn;

    public Image(final JsonObject json) {
        ImageConverter.fromJson(json, this);
        this.id = StringUtils.isEmpty(json.getString("id")) ?
            UUIDUtils.genId() : json.getString("id");
    }

    public JsonObject toJson() {
        final JsonObject json = new JsonObject();
        ImageConverter.toJson(this, json);
        return json;
    }

    public String getId() {
        return this.id;
    }

    public String getImagePath() {
        return this.imagePath;
    }

    public void setImagePath(final String imagePath) {
        this.imagePath = imagePath;
    }

    public String getImageBase() {
        return this.imageBase;
    }

    public void setImageBase(final String imageBase) {
        this.imageBase = imageBase;
    }

    public long getCreatedOn() {
        return this.createdOn;
    }

    public void setCreatedOn(final long createdOn) {
        this.createdOn = createdOn;
    }
}
